import socket
url = '127.0.0.1'
port = 8000
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((url, port))
request_url = 'GET / HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\n\r\n'
sock.send(request_url.encode())

response = b''
while True:
    data = sock.recv(1024)
    if not data:
        break
    response += data
print(response.decode())

